#include "gtksettingsprivate.h"
#include "gtksnapshot.h"
#include "gtkstyleproviderprivate.h"
+#include "gtksymbolicpaintable.h"
#include "gtkiconthemeprivate.h"
G_DEFINE_TYPE (GtkCssImageIconTheme, _gtk_css_image_icon_theme, GTK_TYPE_CSS_IMAGE)
gtk_snapshot_save (snapshot);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
}
- gtk_icon_paintable_snapshot_with_colors (icon, snapshot,
- icon_width,
- icon_height,
- &icon_theme->color,
- &icon_theme->success,
- &icon_theme->warning,
- &icon_theme->error);
+ gtk_symbolic_paintable_snapshot_symbolic (GTK_SYMBOLIC_PAINTABLE (icon),
+ snapshot,
+ icon_width,
+ icon_height,
+ icon_theme->colors,
+ G_N_ELEMENTS (icon_theme->colors));
if (x != 0 || y != 0)
gtk_snapshot_restore (snapshot);
}
copy->icon_theme = gtk_icon_theme_get_for_display (display);
copy->serial = gtk_icon_theme_get_serial (copy->icon_theme);
copy->scale = gtk_style_provider_get_scale (provider);
- gtk_icon_theme_lookup_symbolic_colors (style, ©->color, ©->success, ©->warning, ©->error);
+ gtk_icon_theme_lookup_symbolic_colors (style, ©->colors[0], ©->colors[3], ©->colors[2], ©->colors[1]);
return GTK_CSS_IMAGE (copy);
}
GtkCssImage parent;
GtkIconTheme *icon_theme;
- GdkRGBA color;
- GdkRGBA success;
- GdkRGBA warning;
- GdkRGBA error;
+ GdkRGBA colors[4];
int serial;
int scale;
char *name;
#include "gtkiconcacheprivate.h"
#include "gtkintl.h"
#include "gtkmain.h"
+#include "gtkprivate.h"
#include "gtksettingsprivate.h"
+#include "gtksnapshot.h"
#include "gtkstylecontextprivate.h"
#include "gtkstyleproviderprivate.h"
-#include "gtkprivate.h"
-#include "gtksnapshot.h"
+#include "gtksymbolicpaintable.h"
#include "gtkwidgetprivate.h"
#include "gdkpixbufutilsprivate.h"
#include "gdk/gdktextureprivate.h"
*/
static void icon_paintable_init (GdkPaintableInterface *iface);
+static void icon_symbolic_paintable_init (GtkSymbolicPaintableInterface *iface);
enum
{
G_DEFINE_TYPE_WITH_CODE (GtkIconPaintable, gtk_icon_paintable, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
- icon_paintable_init))
+ icon_paintable_init)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_SYMBOLIC_PAINTABLE,
+ icon_symbolic_paintable_init))
static void
gtk_icon_paintable_init (GtkIconPaintable *icon)
double width,
double height)
{
- GtkIconPaintable *icon = GTK_ICON_PAINTABLE (paintable);
-
- gtk_icon_paintable_snapshot_with_colors (icon, snapshot, width, height,
- NULL, NULL, NULL, NULL);
+ gtk_symbolic_paintable_snapshot_symbolic (GTK_SYMBOLIC_PAINTABLE (paintable), snapshot, width, height, NULL, 0);
}
-/**
- * gtk_icon_paintable_snapshot_with_colors:
- * @icon: a `GtkIconPaintable`
- * @snapshot: a `GdkSnapshot` to snapshot to
- * @width: width to snapshot in
- * @height: height to snapshot in
- * @foreground_color: (nullable): a `GdkRGBA` representing the foreground color
- * of the icon or %NULL to use the default color.
- * @success_color: (nullable): a `GdkRGBA` representing the warning color
- * of the icon or %NULL to use the default color
- * @warning_color: (nullable): a `GdkRGBA` representing the warning color
- * of the icon or %NULL to use the default color
- * @error_color: (nullable): a `GdkRGBA` representing the error color
- * of the icon or %NULL to use the default color
- *
- * Snapshots the `GtkIconPaintable`.
- *
- * This is similar to the implementation of [method@Gdk.Paintable.snapshot],
- * but if the icon is symbolic it will be recolored with the specified colors
- * (which usually comes from the theme).
- */
-void
-gtk_icon_paintable_snapshot_with_colors (GtkIconPaintable *icon,
- GtkSnapshot *snapshot,
- double width,
- double height,
- const GdkRGBA *foreground_color,
- const GdkRGBA *success_color,
- const GdkRGBA *warning_color,
- const GdkRGBA *error_color)
+static void
+gtk_icon_paintable_snapshot_symbolic (GtkSymbolicPaintable *paintable,
+ GtkSnapshot *snapshot,
+ double width,
+ double height,
+ const GdkRGBA *colors,
+ gsize n_colors)
{
+ GtkIconPaintable *icon = GTK_ICON_PAINTABLE (paintable);
GdkTexture *texture;
int texture_width, texture_height;
double render_width;
graphene_vec4_t offset;
init_color_matrix (&matrix, &offset,
- foreground_color, success_color,
- warning_color, error_color);
+ &colors[0], &colors[3],
+ &colors[2], &colors[1]);
gtk_snapshot_push_color_matrix (snapshot, &matrix, &offset);
}
iface->get_intrinsic_height = icon_paintable_get_intrinsic_height;
}
+static void
+icon_symbolic_paintable_init (GtkSymbolicPaintableInterface *iface)
+{
+ iface->snapshot_symbolic = gtk_icon_paintable_snapshot_symbolic;
+}
+
/**
* gtk_icon_paintable_new_for_file:
* @file: a `GFile`
GdkRGBA *success_out,
GdkRGBA *warning_out,
GdkRGBA *error_out);
-void gtk_icon_paintable_snapshot_with_colors (GtkIconPaintable *icon,
- GtkSnapshot *snapshot,
- double width,
- double height,
- const GdkRGBA *foreground_color,
- const GdkRGBA *success_color,
- const GdkRGBA *warning_color,
- const GdkRGBA *error_color);
int gtk_icon_theme_get_serial (GtkIconTheme *self);
#include "gtkcsstransformvalueprivate.h"
#include "gtkiconthemeprivate.h"
#include "gtksnapshot.h"
+#include "gtksymbolicpaintable.h"
#include "gsktransform.h"
#include <math.h>
{
GskTransform *transform;
gboolean has_shadow;
- gboolean is_icon_paintable;
- GdkRGBA fg, sc, wc, ec;
+ gboolean is_symbolic_paintable;
+ GdkRGBA colors[4];
g_return_if_fail (GTK_IS_CSS_STYLE (style));
g_return_if_fail (snapshot != NULL);
has_shadow = gtk_css_shadow_value_push_snapshot (style->icon->icon_shadow, snapshot);
- is_icon_paintable = GTK_IS_ICON_PAINTABLE (paintable);
- if (is_icon_paintable)
+ is_symbolic_paintable = GTK_IS_SYMBOLIC_PAINTABLE (paintable);
+ if (is_symbolic_paintable)
{
- gtk_icon_theme_lookup_symbolic_colors (style, &fg, &sc, &wc, &ec);
+ gtk_icon_theme_lookup_symbolic_colors (style, &colors[0], &colors[3], &colors[2], &colors[1]);
- if (fg.alpha == 0.0f)
+ if (gdk_rgba_is_clear (&colors[0]))
goto transparent;
}
if (transform == NULL)
{
- if (is_icon_paintable)
- gtk_icon_paintable_snapshot_with_colors (GTK_ICON_PAINTABLE (paintable), snapshot, width, height, &fg, &sc, &wc, &ec);
+ if (is_symbolic_paintable)
+ gtk_symbolic_paintable_snapshot_symbolic (GTK_SYMBOLIC_PAINTABLE (paintable), snapshot, width, height, colors, G_N_ELEMENTS (colors));
else
gdk_paintable_snapshot (paintable, snapshot, width, height);
}
gtk_snapshot_transform (snapshot, transform);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (- width / 2.0, - height / 2.0));
- if (is_icon_paintable)
- gtk_icon_paintable_snapshot_with_colors (GTK_ICON_PAINTABLE (paintable), snapshot, width, height, &fg, &sc, &wc, &ec);
+ if (is_symbolic_paintable)
+ gtk_symbolic_paintable_snapshot_symbolic (GTK_SYMBOLIC_PAINTABLE (paintable), snapshot, width, height, colors, G_N_ELEMENTS (colors));
else
gdk_paintable_snapshot (paintable, snapshot, width, height);